<?php

class Pictures_Image_DeleteAction extends BlogPicturesBaseAction
{
    /**
     * Process HTTP GET request
     *
     * @param AgaviRequestDataHolder $rd
     * @return string
     */
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        return 'Success';
    }
    
    /**
     * Process HTTP POST request
     *
     * @param AgaviRequestDataHolder $rd
     * @return string
     */
    public function executeWrite(AgaviRequestDataHolder $rd)
    {
		$params = $rd->getParameters();
		$pic_id = $params['pic_id'];
        /* @var $model Pictures_PicturesModel */
		$model = $this->getContext()->getModel('Pictures', 'Pictures');
		
	    // try to delete
		$model->deletePicture($pic_id);
	    $this->setAttribute('ok', true);

		return 'Success';
    }
    
	/**
	 * Returns the default view if the action does not serve the request
	 * method used.
	 *
	 * @return     mixed <ul>
	 *                     <li>A string containing the view name associated
	 *                     with this action; or</li>
	 *                     <li>An array with two indices: the parent module
	 *                     of the view to be executed and the view to be
	 *                     executed.</li>
	 *                   </ul>
	 */
	public function getDefaultViewName()
	{
		return 'Success';
	}
}

?>